package org.wdh.ep.sct.af;

public class Cons implements List {
	Object first;
	List rest;
	Cons(Object _first) {
		this.first = _first;
		this.rest = new Empty();
	}
	Cons(Object _first, List _rest) {
		this.first = _first;
		this.rest = _rest;
	}
	public Object getFirst() { return this.first; }
	public List getRest() {	return this.rest; }
	public boolean equals(Object that) {
		if(this.getClass() == that.getClass()) {
			Cons _that = (Cons)that;
			boolean firstEltsMatch = this.getFirst().equals(_that.getFirst());
			boolean restEltsMathch = this.getRest().equals(_that.getRest());
			return firstEltsMatch && restEltsMathch;
		}
		else {
			return false;
		}
	}
}
